package com.mz.ozy.mvp.presenter;

import android.app.Activity;

import com.mz.ozy.base.BasePresenterImpl;
import com.mz.ozy.bean.NewJoinMemListBean;
import com.mz.ozy.mvp.model.JoinMemberModel;
import com.mz.ozy.mvp.view.JoinMemberContract;
import com.mz.ozy.net.MyObserver;
import com.mz.ozy.utils.RxUtil;

import org.json.JSONObject;

import okhttp3.ResponseBody;

public class JoinMemberPresenter extends BasePresenterImpl<JoinMemberContract.View> implements JoinMemberContract.Presenter{

    private JoinMemberModel mModel;

    public JoinMemberPresenter(){
        mModel = new JoinMemberModel();
    }


    @Override
    public void list(Activity activity) {
        mModel.list(activity)
                .compose(RxUtil.rxSchedulerHelper(mView.<ResponseBody>bindToLifecycle()))
                .subscribe(new MyObserver<NewJoinMemListBean>(mView,false){
                    @Override
                    public void onSuccesss(NewJoinMemListBean bean) {
                        mView.listSuccess(bean);
                    }
                });
    }

    @Override
    public void join(Activity activity, String phone, String fid, String gift, String payType, String payPwd) {
        mModel.join(activity, phone, fid, gift, payType, payPwd)
                .compose(RxUtil.rxSchedulerHelper(mView.<ResponseBody>bindToLifecycle()))
                .subscribe(new MyObserver<JSONObject>(mView,false){
                    @Override
                    public void onSuccesss(JSONObject bean) {
                        mView.joinSuccess(bean);
                    }
                });
    }

    @Override
    public void handReport(Activity activity, String userId, String phone, String fid, String gift, String payType, String payPwd) {
        mModel.handReport(activity, userId, phone, fid, gift, payType, payPwd)
                .compose(RxUtil.rxSchedulerHelper(mView.<ResponseBody>bindToLifecycle()))
                .subscribe(new MyObserver<JSONObject>(mView,false){
                    @Override
                    public void onSuccesss(JSONObject bean) {
                        mView.handReportSuccess(bean);
                    }
                });
    }

}

